<script setup lang="ts">
import { testStore } from '@/store/test'
import { computed } from 'vue';

const store = testStore();
const count = computed(() => {
  return store.getCount;
});

const addBtn = () => {
  // 直接改，有时会失效
  // store.count++;
  // 用action(推荐)
  store.setCount(++store.count)

  // store.$patch({
  //   count:++store.count
  // });

  // store.$patch((state) => {
  //   state.count = ++store.count
  // });

};

</script>

<template>
  <h1>{{ count }}</h1>

  <el-button icon="Plus" type="primary" @click="addBtn">自增</el-button>
  <!-- 加图标 -->
  <el-icon :size="20">
    <Edit />
  </el-icon>
  <el-button type="success">Success</el-button>
</template>

<style scoped></style>
